//
//  ViewController.m
//  HZ_Beautiful_Music
//
//  Created by dllo on 16/3/30.
//  Copyright © 2016年 ui. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()<UIScrollViewDelegate>
@property (nonatomic, assign) BOOL isQut;
@property (nonatomic, strong) NSArray *array;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    self.array = [NSArray arrayWithObjects:@"31.jpg", @"32.jpg", @"33.jpg", nil];
    
    
    UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:self.view.bounds];
    
    scroll.contentSize = CGSizeMake(self.array.count * self.view.bounds.size.width, self.view.bounds.size.height);
    scroll.pagingEnabled = YES;
    scroll.delegate = self;
    [self.view addSubview:scroll];
    
    
    for (int i = 0; i < self.array.count; i++) {
        UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(i * self.view.bounds.size.width, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
        
        image.image = [UIImage imageNamed:self.array[i]];
        [scroll addSubview:image];
        
    }

    
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    if (scrollView.contentOffset.x > (self.array.count - 1) * self.view.bounds.size.width + 20) {
        _isQut = YES;
    }
}


-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    
    if (_isQut == YES) {
        
        
        NSNotificationCenter *isqut = [NSNotificationCenter defaultCenter];

        
        [isqut postNotificationName:@"10" object:@"1" userInfo:nil];

        
    }

    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
